// Licensed to Elasticsearch B.V under one or more agreements.
// Elasticsearch B.V licenses this file to you under the Apache 2.0 License.
// See the LICENSE file in the project root for more information.
//
// ███╗   ██╗ ██████╗ ████████╗██╗ ██████╗███████╗
// ████╗  ██║██╔═══██╗╚══██╔══╝██║██╔════╝██╔════╝
// ██╔██╗ ██║██║   ██║   ██║   ██║██║     █████╗
// ██║╚██╗██║██║   ██║   ██║   ██║██║     ██╔══╝
// ██║ ╚████║╚██████╔╝   ██║   ██║╚██████╗███████╗
// ╚═╝  ╚═══╝ ╚═════╝    ╚═╝   ╚═╝ ╚═════╝╚══════╝
// ------------------------------------------------
//
// This file is automatically generated.
// Please do not edit these files manually.
//
// ------------------------------------------------

using System;
using System.Collections.Generic;
using System.Linq.Expressions;
using System.Text.Json;
using System.Text.Json.Serialization;

#nullable restore
namespace Elastic.Clients.Elasticsearch.Security
{
	public sealed partial class IndexPrivilegesCheck
	{
		[JsonInclude]
		[JsonPropertyName("allow_restricted_indices")]
		public bool? AllowRestrictedIndices { get; set; }

		[JsonInclude]
		[JsonPropertyName("names")]
		public Elastic.Clients.Elasticsearch.Indices Names { get; set; }

		[JsonInclude]
		[JsonPropertyName("privileges")]
		public IEnumerable<Elastic.Clients.Elasticsearch.Security.IndexPrivilege> Privileges { get; set; }
	}

	public sealed partial class IndexPrivilegesCheckDescriptor : SerializableDescriptorBase<IndexPrivilegesCheckDescriptor>
	{
		internal IndexPrivilegesCheckDescriptor(Action<IndexPrivilegesCheckDescriptor> configure) => configure.Invoke(this);
		public IndexPrivilegesCheckDescriptor() : base()
		{
		}

		private bool? AllowRestrictedIndicesValue { get; set; }

		private Elastic.Clients.Elasticsearch.Indices NamesValue { get; set; }

		private IEnumerable<Elastic.Clients.Elasticsearch.Security.IndexPrivilege> PrivilegesValue { get; set; }

		public IndexPrivilegesCheckDescriptor AllowRestrictedIndices(bool? allowRestrictedIndices = true)
		{
			AllowRestrictedIndicesValue = allowRestrictedIndices;
			return Self;
		}

		public IndexPrivilegesCheckDescriptor Names(Elastic.Clients.Elasticsearch.Indices names)
		{
			NamesValue = names;
			return Self;
		}

		public IndexPrivilegesCheckDescriptor Privileges(IEnumerable<Elastic.Clients.Elasticsearch.Security.IndexPrivilege> privileges)
		{
			PrivilegesValue = privileges;
			return Self;
		}

		protected override void Serialize(Utf8JsonWriter writer, JsonSerializerOptions options, IElasticsearchClientSettings settings)
		{
			writer.WriteStartObject();
			if (AllowRestrictedIndicesValue.HasValue)
			{
				writer.WritePropertyName("allow_restricted_indices");
				writer.WriteBooleanValue(AllowRestrictedIndicesValue.Value);
			}

			writer.WritePropertyName("names");
			JsonSerializer.Serialize(writer, NamesValue, options);
			writer.WritePropertyName("privileges");
			JsonSerializer.Serialize(writer, PrivilegesValue, options);
			writer.WriteEndObject();
		}
	}
}